﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Skyhook.Core;

namespace Skyhook.Logic
{
    class LogicObject<T> : ILogic where T : VisualController, new()
    {
        protected IObjectController ObjectController = null;
        protected T VisualController = null;

        public LogicObject(string assetname, int startx, int starty)
        {
            IVisualObject visual = VisualsFactory.CreateCommonVisual(assetname);

            VisualController = new T();
            VisualController.SetVisualObject(visual);

            ObjectController = ObjectsEngine.CreateObject(this, visual);
            ObjectController.Put(startx + 0.5f, starty + 0.5f);

            Initialize();
        }

        protected virtual void Initialize()
        {
        }

        public void Delete()
        {
            ObjectController.Delete();
            ObjectController = null;
        }

        public float X
        {
            get
            {
                return ObjectController.X;
            }
        }

        public float Y
        {
            get
            {
                return ObjectController.Y;
            }
        }
    }
}
